<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>邀请好友</title>
	<link rel="shortcut icon" href="https://gtms04.alicdn.com/tps/i4/TB1_oz6GVXXXXaFXpXXJDFnIXXX-64-64.ico" type="image/x-icon"/>
	<link rel="stylesheet" href="https://g.alicdn.com/thx/cube/1.3.2/cube.min.css">
	<link rel="stylesheet" href="/wjfh/css/iconfont.css">
	<link rel="stylesheet" type="text/css" href="/wjfh/css/common.css"/>
	<link rel="stylesheet" type="text/css" href="/wjfh/layui/css/layui.css"/>
	<link rel="stylesheet" type="text/css" href="/wjfh/css/style.css"/>
	<script src="/wjfh/js/flexible.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
	<div class="resgcontain">
		<div class="shareimg"><img class="openshare" src="/wjfh/img/yaoqing.png" alt=""></div>
		<div class="sharetit">分享·邀请码</div>
		<div class="sharecode"><span id="invite"></span></div>
		<div style="height: 15px;"></div>
	</div>
	<div class="resgcontain">
		<div class="qrcode">
			<div id="qrcode"></div>
			<p>长按保存二维码</p>
		</div>

	</div>
	<div class="resgcontain">
		<!--<h2 class="shareez">每邀请一个代理出货总部会给您奖励<span>80</span>元</h2>-->
		<h2 class="shareez">欢迎开启五季芳禾健康事业！<br>
			往后余生，健康是你，富有是你……
		</h2>
		<div class="sharefoot">
			<button class="firendquanbtn openshare"><i class="icon iconfont"></i>朋友圈分享</button>
			<button class="firendbtn openshare"><i class="icon iconfont"></i>好友分享</button>
		</div>
		<div style="height: 15px;"></div>
	</div>
	<div class="sharemb"></div>
	<script src="/wjfh/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script src="/wjfh/js/vue.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="/wjfh/js/axios.js" type="text/javascript" charset="utf-8"></script>
	<script src="/js/jquery.min.js?v=2.1.4" th:src="@{/js/jquery.min.js?v=2.1.4}"></script>
	<!-- 实现网址生成二维码 -->
	<script type="text/javascript" src="http://static.runoob.com/assets/qrcode/qrcode.min.js"></script>
	<script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
	<script>
    window.onload = function () {
        layui.use(['jquery', 'form','layer'], function() {
            $ = layui.jquery,
                form = layui.form,
                layer = layui.layer;
            var invite;
            layer.ready(function(){
                layer.load(1);
            });

            $.ajax({
                cache: true,
                type: "POST",
                url: "/goodsManager/retail/mine",

                error: function (request) {
                    layer.alert("Connection error");
                },
                success: function (data) {
                    console.log(data);
                    if (data.code == 500) {
                        parent.location.href = '/goodsManager/page/login';
                    } else {
                        invite = data.invite;
                        $("#invite").text(data.invite);
                        layer.closeAll('loading');
                        makeCode();
                        var link = location.href.split('#')[0];
                        $.ajax({
                            //cache: false,
                            type: "GET",
                            data:{"url":link},
                            url: "/wechat/wechatParam",
                            error : function(request) {
                                layer.alert("Connection error");
                            },
                            success : function(data) {
                                console.log(data);
                                wx.config({
                                    debug: false,
                                    appId: data.appid,
                                    timestamp: data.timestamp,
                                    nonceStr: data.nonceStr,
                                    signature: data.signature,
                                    jsApiList: [
                                        'checkJsApi',
                                        'onMenuShareTimeline',
                                        'onMenuShareAppMessage',
                                        'onMenuShareQQ',
                                        'onMenuShareWeibo',
                                        'hideMenuItems',
                                        'showMenuItems',
                                        'hideAllNonBaseMenuItem',
                                        'showAllNonBaseMenuItem',
                                        'translateVoice',
                                        'startRecord',
                                        'stopRecord',
                                        'onRecordEnd',
                                        'playVoice',
                                        'pauseVoice',
                                        'stopVoice',
                                        'uploadVoice',
                                        'downloadVoice',
                                        'chooseImage',
                                        'previewImage',
                                        'uploadImage',
                                        'downloadImage',
                                        'getNetworkType',
                                        'openLocation',
                                        'getLocation',
                                        'hideOptionMenu',
                                        'showOptionMenu',
                                        'closeWindow',
                                        'scanQRCode',
                                        'chooseWXPay',
                                        'openProductSpecificView',
                                        'addCard',
                                        'chooseCard',
                                        'openCard'
                                    ]

                                });
                            }
                        });
                        wx.ready(function () {
                            wx.onMenuShareTimeline({
                                title: '欢迎开启五季芳禾健康事业！', // 分享标题
                                desc: '往后余生，健康是你，富有是你……', // 分享描述
                                link: 'http://5jfh.cn/goodsManager/page/resg?code='+invite, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                                imgUrl: 'http://5jfh.cn/wjfh/img/banner.jpg', // 分享图标
                                success: function () {
                                    $(".sharemb").show();
                                    // 用户确认分享后执行的回调函数
                                },
                                cancel: function () {
                                    $(".sharemb").show();
                                    // 用户取消分享后执行的回调函数
                                }
                            });
                            wx.onMenuShareAppMessage({
                                title: '欢迎开启五季芳禾健康事业！', // 分享标题
                                desc: '往后余生，健康是你，富有是你……', // 分享描述
                                link: 'http://5jfh.cn/goodsManager/page/resg?code='+invite, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                                imgUrl: 'http://5jfh.cn/wjfh/img/banner.jpg', // 分享图标
                                type: 'link', // 分享类型,music、video或link，不填默认为link
                                dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                                success: function () {
                                    $(".sharemb").show();
                                },
                                cancel: function () {
                                    $(".sharemb").show();
                                }
                            });
                        })
                    }


                }
            });
            $(".sharemb").on("click",function () {
                $(".sharemb").hide();
            })
            $(".openshare").on("click",function () {
                $(".sharemb").show();
            })

            // 二维码图片的大小
            var qrcode = new QRCode(document.getElementById("qrcode"), {
                width : 100,
                height : 100
            });

            // 根据url生成二维码
            function makeCode () {
                var elText = 'http://www.5jfh.cn/goodsManager/page/resg?code='+invite;
                $('#CopyHref').attr('data-clipboard-text',elText);
                qrcode.makeCode(elText);
            }

        })
    }
	</script>



</body>
</html>
